﻿using LxCore;

namespace LxCore
{
    public class LxInfo : JsObject
    {
        public LxInfo()
        {
        }
        public string AppName
        {
            get => "流形";
        }
        public string AppVersion
        {
            get => "Lx202412";
        }
        private string _FileVersion = string.Empty;
        public string FileVersion
        {
            get => _FileVersion;
            set
            {
                _FileVersion = value;
                RaisePropertyChanged(nameof(FileVersion));
            }
        }

        public string FilePath
        {
            get => $"{Directory}\\{ProjName}.json";
            set
            {
                Directory = Path.GetDirectoryName(value);
                ProjName = Path.GetFileNameWithoutExtension(value);
                RaisePropertyChanged(nameof(FilePath));
            }
        }

        private string _Directory = string.Empty;
        public string Directory
        {
            get { return _Directory; }
            set { _Directory = value; RaisePropertyChanged(nameof(Directory)); }
        }

        private string _ProjName = string.Empty;
        public string ProjName
        {
            get => _ProjName;
            set { _ProjName = value; RaisePropertyChanged(nameof(ProjName)); }
        }
        public override void ToJsonKV(IJsonWriter writer)
        {
            writer.WriteString("Version", AppVersion);
            base.ToJsonKV(writer);
        }
        public override void FromJsonKV(string key, IJsonReader jsReader)
        {
            switch (key)
            {
                case "Version": FileVersion = jsReader.ReadString(); break;
                default: base.FromJsonKV(key, jsReader); break;
            }
        }
    }
}
